/**
 * Created by Administrator on 2018/5/31.
 */


var points = [
    {'name':'宝兴县', 'pos':[102.82058,30.388173]},
    {'name':'天全县', 'pos':[102.778663,30.063344]},
    {'name':'荥经县', 'pos':[102.853267,29.799434]},
    {'name':'芦山县', 'pos':[102.939033,30.148236]},
    {'name':'汉源县', 'pos':[102.657688,29.349799]},
    {'name':'石棉县', 'pos':[102.365654,29.234244]},
    {'name':'名山区', 'pos':[103.115734,30.0759]},
    {'name':'雨城区', 'pos':[103.039693,30.011103]}

];

function drawPie(id){
    var echartData = [{
        value: 196,
        name: '管理学'
    }, {
        value: 218,
        name: '经济学'
    }, {
        value: 59,
        name: '法学'
    }, {
        value: 76,
        name: '历史学'
    }, {
        value: 144,
        name: '教育学'
    }, {
        value: 41,
        name: '哲学'
    }, {
        value: 83,
        name: '文学'
    }, {
        value: 45,
        name: '工学'
    }];

    var rich = {
        total: {
            color: "#ffc72b",
            fontSize: 40,
            align: 'center'
        }
    };

    var option = {
        //backgroundColor: '#031f2d',
        title: [{
            text: '专业分布',
            left: 'center',
            top: '53%',
            padding: [24, 0],
            textStyle: {
                color: '#000',
                fontSize: 14,
                align: 'center'
            }
        },{
            text: '干部专业分布',
            left: 'left',
            textStyle: {
                color: '#000',
                fontSize: 14,
                align: 'center'
            }
        }],
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            selectedMode: false,
            formatter: function(name) {
                var total = 0; //各科正确率总和
                echartData.forEach(function(value, index, array) {
                    //total += value.value;
                    total = array.length;
                });
                return '共计{total|' + total + '}个专业';
            },
            data: [echartData[0].name],
            left: 'center',
            top: 'center',
            icon: 'none',
            align: 'center',
            textStyle: {
                color: "#000",
                fontSize: 16,
                rich: rich
            },
        },
        series: [{
            name: '',
            type: 'pie',
            radius: ['40%', '55%'],
            label: {
                normal: {
                    //formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                    formatter: '{b|{b}：}{c}  {per|{d}%}  ',
                    backgroundColor: '#eee',
                    borderColor: '#aaa',
                    borderWidth: 1,
                    borderRadius: 4,
                    rich: {
                        a: {
                            color: '#999',
                            lineHeight: 22,
                            align: 'center'
                        },
                        hr: {
                            borderColor: '#aaa',
                            width: '100%',
                            borderWidth: 0.5,
                            height: 0
                        },
                        b: {
                            fontSize: 16,
                            lineHeight: 33
                        },
                        per: {
                            color: '#eee',
                            backgroundColor: '#334455',
                            padding: [2, 4],
                            borderRadius: 2
                        }
                    }
                }
            },
            data: echartData
        }]
    };
    Init3(option, id);
}

function drawPoints(id){
    var data = [
        [[28604,77,17096869,'张**',1990],[31163,77.4,27662440,'王*',1990],[1516,68,1154605773,'张*',1990],[13670,74.7,10582082,'张**',1990],
            [28599,75,4986705,'赵**',1990],[29476,77.1,56943299,'李*',1990],[31476,75.4,78958237,'李*',1990],[28666,78.1,254830,'李*',1990],
            [1777,57.7,870601776,'刘*',1990],[29550,79.1,122249285,'冯*',1990],[2076,67.9,20194354,'刘**',1990],[12087,72,42972254,'周*',1990],
            [24021,75.4,3397534,'李*',1990],[43296,76.8,4240375,'王*',1990],[10088,70.8,38195258,'宋*',1990],[19349,69.6,147568552,'张*',1990],
            [10670,67.3,53994605,'周**',1990],[26424,75.7,57110117,'黄*',1990],[37062,75.4,252847810,'钱**',1990]],
        [[44056,81.8,23968973,'张*',2015],[43294,81.7,35939927,'王*',2015],[13334,76.9,1376048943,'张*',2015],[21291,78.5,11389562,'王*',2015],
            [38923,80.8,5503457,'郑**',2015],[37599,81.9,64395345,'刘*',2015],[44053,81.1,80688545,'钱*',2015], [42182,82.8,329425,'冯*',2015],
            [5903,66.8,1311050527,'郑*',2015],[36162,83.5,126573481,'李*',2015],[1390,71.4,25155317,'宋**',2015],[34644,80.7,50293439,'李**',2015],
            [34186,80.6,4528526,'周**',2015],[64304,81.6,5210967,'刘*',2015],[24787,77.3,38611794,'李**',2015],[23038,73.13,143456918,'孙*',2015],
            [19360,76.5,78665830,'李**',2015],[38225,81.4,64715810,'孙**',2015],[53354,79.1,321773631,'孙*',2015]]
    ];

    var option = {
        title: {
            text: '干部在职离职数据分析',
            textStyle:{ //color:'#fff',
                fontSize:14
            }
        },
        legend: {
            left: 'center',
            data: ['宝兴县', '天泉县']
        },
        grid:{left:40, right:40, top:'15%'},
        xAxis: {
            name:'年龄',
            splitLine: {
                lineStyle: {
                    type: 'dashed',
                    //color:'#fff'
                }
            },
            //axisLabel:{ color:'#fff' },
            //nameTextStyle:{ color:'#fff' }
        },
        yAxis: {
            name:'工作年限',
            splitLine: {
                lineStyle: {
                    type: 'dashed'
                }
            },
            //axisLabel:{ color:'#fff' },
            scale: true,
            //nameTextStyle:{ color:'#fff' }
        },
        series: [{
            name: '在职',
            data: data[0],
            type: 'scatter',
            symbolSize: function (data) {
                return Math.sqrt(data[2]) / 5e2;
            },
            label: {
                emphasis: {
                    show: true,
                    formatter: function (param) {
                        return param.data[3];
                    },
                    position: 'top'
                }
            },
            itemStyle: {
                normal: {
                    shadowBlur: 10,
                    shadowColor: 'rgba(120, 36, 50, 0.5)',
                    shadowOffsetY: 5,
                    color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                        offset: 0,
                        color: 'rgb(251, 118, 123)'
                    }, {
                        offset: 1,
                        color: 'rgb(204, 46, 72)'
                    }])
                }
            }
        }, {
            name: '退休',
            data: data[1],
            type: 'scatter',
            symbolSize: function (data) {
                return Math.sqrt(data[2]) / 5e2;
            },
            label: {
                emphasis: {
                    show: true,
                    formatter: function (param) {
                        return param.data[3];
                    },
                    position: 'top'
                }
            },
            itemStyle: {
                normal: {
                    shadowBlur: 10,
                    shadowColor: 'rgba(25, 100, 150, 0.5)',
                    shadowOffsetY: 5,
                    color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                        offset: 0,
                        color: 'rgb(129, 227, 238)'
                    }, {
                        offset: 1,
                        color: 'rgb(25, 183, 207)'
                    }])
                }
            }
        }]
    };

    var e = Init3(option, id);
    e.on('click', function(){
        drawBar("r3");
    });
}


